
$(function(){
    $("#Switch>span").eq(0).on("click",function(){
        $(this).css("border-bottom","1px solid green").siblings().css("border-bottom","none");
        $("#Channel1").css("display","block");
        $("#Channel2").css("display","none");
    });
    $("#Switch>span").eq(1).on("click",function(){
        $(this).css("border-bottom","1px solid green").siblings().css("border-bottom","none");
        $("#Channel1").css("display","none");
        $("#Channel2").css("display","block");
    });
    function Confirm_code (){
        var arr = [0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
        var arr1 = [];
        for(var i = 0;i<4;i++){
            arr1.push(arr[parseInt(Math.random()*arr.length)]);
        }
        var str = ""+arr1[0]+arr1[1]+arr1[2]+arr1[3];
        $("#uConfirm_code").text(str);
        return str;
    }
    Confirm_code();
    $("#uSwitch").on("click",function(){
        Confirm_code();
    });
    $("#uBtn").on("click",function(){
        //获取文本的值，发送的服务器
        $.ajax({
            url:"http://localhost/PHP/Epet_sever_login.php",
            type:"post",
            data:$("#uLogin").serialize(),
            success:function(result){
                var obj=JSON.parse(result);
                if(obj.status==1){
                    if($("#uCb").prop("checked")){
                        $.cookie("uName",$("#uName").val(),{path:"/",expires:10});
                        $.cookie("uPwd",$("#uPwd").val(),{path:"/",expires:10});
                        window.location.href="http://localhost:63342/mycode/html/Main_page.html";
                    }else{
                        $.cookie("uName",$("#uName").val(),{path:"/"});
                        $.cookie("uPwd",$("#uPwd").val(),{path:"/"});
                        window.location.href="http://localhost:63342/mycode/html/Main_page.html";
                    }
                }else{
                    alert("用户名或密码错误!");
                }
            }
        })
    })
});
